Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport recent subscriber and attributes changes #1300

Merged
merged 7 commits into from
Mar 12, 2021
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Mar 12, 2021

This backports PRs #1289, #1282, #1290, #1297, #1275, #1277, and #1240 from the master branch to v0.1.x. This will let us publish new releases of tracing-attributes (with a fix for #1296) and tracing-subscriber (with several fixes & API additions).

I'll go ahead and rebase-merge this when CI passes

Folyd and others added 7 commits March 12, 2021 10:55
…1289)

This backports #1289 from `master`.

This PR aims to remove a lot of initializer boilerplate code by adopting
the`struct update syntax.  If the [RFC 2528]  gets merged and
implemented, we can remove more. 😸

[RFC 2528]: rust-lang/rfcs#2528
As far as I can tell, we are not relying on transparency anywhere, so
using this rather refined feature here is confusing.
…utures (#1297)

This backports #1297 from `master`.

Fixes #1296.

I had forgotten to use all the input statements in #1228, so we would
delete nearly all the statement of sync functions that return a boxed
future :/
## Motivation

This fixes #1212, where extra padding was written when logging with the
pretty formatter.

## Solution 

With this change we only write padding when we actually decide to write
a value but not when skipping a metadata value such as `log.file` or
`log.line`
This backports #1277 from `master`.

Fixes #1136.

Allows arbitrarily combining different FmtSpan events to listen to.

Motivation
----------

The idea is to allow any combination of `FmtSpan` options, such as the
currently unachievable combination of `FmtSpan::NEW | FmtSpan::CLOSE`.

Solution
--------

Make `FmtSpan` behave like a bitflag that can be combined using the
bitwise or operator ( `|` ) while maintaining backward compatibility by
keeping the same names for all existing presets and keeping the
implementation details hidden.
This backports #1240 from `master`.

* subscriber: update pretty formatter for no ansi

 ## Background

    Currently, when the `Pretty` event formatter is being used, it does
    not change its output when the `with_ansi` flag is set to false by
    the `CollectorBuilder`.

 ## Overview

    While this formatter is generally used in situations such as local
    development, where ANSI escape codes are more often acceptable,
    there are some situations in which this can lead to mangled output.

    This commit makes some minor changes to account for this `ansi` flag
    when formatting events using `Pretty`.

    Becuase ANSI codes were previously used to imply the event level
    using colors, this commit additionally modifies `Pretty` so that
    it respects `display_level` when formatting an event.

 ## Changes

    * Changes to `<Format<Pretty, T> as FormatEvent<C, N>>::format_event`

    * Add a `PrettyVisitor::ansi` boolean flag, used in its `Visit`
      implementation.

        * Add a new `PrettyVisitor::with_ansi` builder pattern method to
          facilitate this.

 ## Out of Scope

    One detail worth nothing is that this does not solve the problem of
    *fields* being formatted without ANSI codes. Configuring a
    subscriber using this snippet would still lead to bolded fields in
    parent spans.

```rust
tracing_subscriber::fmt()
    .pretty()
    .with_ansi(false)
    .with_level(false)
    .with_max_level(tracing::Level::TRACE)
    .init();
```

    This can be worked around by using a different field formatter, via
    `.fmt_fields(tracing_subscriber::fmt::format::DefaultFields::new())`
    in the short-term.

    In the long-term, #658 is worth investigating further.

Refs: #658
@hawkw hawkw requested a review from a team as a code owner March 12, 2021 19:10
@hawkw hawkw merged commit ec73134 into v0.1.x Mar 12, 2021
@hawkw hawkw deleted the eliza/backport-1297 branch March 12, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants